package bTree.LeetCode;

public class 平衡分隔字串 {
    public int balancedStringSplit(String s) {
        int res=0;
        int length = s.length();
        int R=0,L=0;
        for (int i = 0; i < length; i++) {
            char c = s.charAt(i);
            if (c=='R'){
                R++;
            }else {
                L++;
            }
            if (R==L){
                res++;
                R=0;
                L=0;
            }
        }
        return res;
    }
}